/*
 * Created on2022/6/11 18:22
 *
 * Copyright(c) YuZhou Big Data Laboratory CO.,Ltd, 2022.  All rights reserved.
 *
 *******************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ******************************************************************************/

package org.yzbdl.lanius.core.plugins.metastore;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;

import javax.persistence.*;

import org.yzbdl.lanius.core.metastore.BaseEntity;

import lombok.Getter;
import lombok.Setter;

/**
 * 核心对象树分类下面的分组信息
 *
 * @author hs@yzbdl.ac.cn
 * @version 1.0
 * @date 2019/6/11 18:22
 */
@Entity
@Table(name = "ldr_category")
@Getter
@Setter
public class LdrCategoryEntity extends BaseEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    protected Integer id;

    /**
     * 所属分类ID
     */
    @Column(name = "classification_id")
    private Integer classificationId;

    // /**
    // * 功能类别, 参照 org.pentaho.di.core.plugins.metastore.FuncType
    // */
    // @Column(name = "func_type")
    // private Integer funcType;

    /**
     * 插件类别, 记录PluginType类的全名
     */
    @Column(name = "plugin_type_class")
    private String pluginTypeClass;

    /**
     * 名称
     */
    @Column(name = "name")
    private String name;

    /**
     * 是否展开
     */
    @Column(name = "expanded")
    private Boolean expanded = false;

    /**
     * 创建时间
     */
    @Column(name = "create_time")
    private Date createTime = new Date();

    /**
     * 排序号
     */
    @Column(name = "sort_num")
    private Integer sortNum;

    @Transient
    private List<LdrPluginEntity> pluginEntities = new ArrayList<>();

    public LdrCategoryEntity() {}

    public LdrCategoryEntity(Integer id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        LdrCategoryEntity that = (LdrCategoryEntity)o;
        return Objects.equals(id, that.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}
